import { useQuery } from "@tanstack/react-query";
import { MaterialDataType } from "./types";

const baseUrl = "https://jsonplaceholder.typicode.com/";

export const fetchUserList = async () => {
  const response = await fetch(baseUrl + "users");
  return await response.json();
};

export const useUserList = () => {
  return useQuery({
    queryKey: ["user-list"],
    queryFn: fetchUserList,
  });
};

// TODO
export const updateMaterialStatus = async (data: {
  id: number;
  status: "enabled" | "disabled";
}): Promise<MaterialDataType> => {
  console.log("TODO: 调用更新素材状态API", data);
  return Promise.resolve({} as MaterialDataType);
};
